package headfirst.factory.simpleFactory.pizzaStore;

import headfirst.factory.simpleFactory.factory.SimplePizzaFactory;

public class PizzaStore {
    SimplePizzaFactory factory;

    public PizzaStore(SimplePizzaFactory factory) {
        this.factory = factory;
    }

    /**
     * 我们把new Pizza() 操作换成了工厂对象的createPizza方法,
     * 不再使用具体的实例化,orderPizza方法通过传入type到工厂,得到想要的pizza
     *
     * @param type
     * @return
     */
    public Pizza orderPizza(String type) {

        Pizza pizza = factory.createPizza(type);

        pizza.prepare();
        pizza.bake();
        pizza.cut();
        pizza.box();

        return pizza;
    }

}
